home *** CD-ROM | disk | FTP | other *** search
/ Best Tools for JAVA / Best Tools for JAVA.iso / JAVA_ALL / IDE / SUBARTIC / SUB_ARCT / TEST / SPEED2.JAV < prev    next >
Encoding:
Text File  |  1996-10-04  |  4.0 KB  |  140 lines

  1. /*
  2.  * $Id: speed2.java,v 1.7 1996/10/03 19:46:51 hudson Exp $
  3.  * $Author: hudson $
  4.  */
  5.  
  6. package sub_arctic.test;
  7.  
  8. import sub_arctic.constraints.std_function;
  9. import sub_arctic.constraints.std_constraint_consts;
  10. import sub_arctic.lib.manager;
  11. import sub_arctic.lib.interactor;
  12. import sub_arctic.lib.base_interactor;
  13. import sub_arctic.lib.base_parent_interactor;
  14. import sub_arctic.lib.interactor_consts;
  15. import sub_arctic.lib.top_level;
  16.  
  17. class bench_interactor extends base_interactor {
  18.   /** W/H only constructor */
  19.   public bench_interactor(int wv, int hv) { super(0,0,wv,hv); }
  20.  
  21.   /** Override set_raw_x so we do not declare screen damage in benchmark */
  22.   public void set_raw_x(int v) { _x = v; }
  23.  
  24.   /** Override set_raw_y so we do not declare screen damage in benchmark */
  25.   public void set_raw_y(int v) { _y = v; }
  26.  
  27.   /** Override set_raw_w so we do not declare screen damage in benchmark */
  28.   public void set_raw_w(int v) { _w = v; }
  29.  
  30.   /** Override set_raw_h so we do not declare screen damage in benchmark */
  31.   public void set_raw_h(int v) { _h = v; }
  32. }
  33.  
  34. public class speed2 implements std_constraint_consts {
  35.  
  36.   static interactor parent;
  37.   static interactor first_child = null;
  38.   static interactor last_child = null;
  39.  
  40.   public static void setup()
  41.     {
  42.       interactor child = null;
  43.  
  44.       
  45.       parent = new base_parent_interactor(0,0,200,200);
  46.       for (int i = 0; i < chain_size; i++)
  47.     {
  48.       child = new bench_interactor(10,10);
  49.       if (first_child == null) 
  50.         first_child = child;
  51.       else
  52.         child.set_x_constraint(std_function.offset(PREV_SIBLING.X(),20));
  53.       parent.add_child(child);
  54.     }
  55.       last_child = child;
  56.  
  57.     } 
  58.  
  59.   public static final int num_trials = 100;
  60.   public static final int chain_size = 500;
  61.     
  62.   public static void test() 
  63.     {
  64.       for (int i = 0; i < num_trials; i++)
  65.     {
  66.       first_child.set_x(i);
  67.       last_child.x();
  68.     }
  69.     }
  70.  
  71.   public static long[] before = new long[num_trials];
  72.   public static long[] mid = new long[num_trials];
  73.   public static long[] after = new long[num_trials];
  74.  
  75.   public static void split_test() 
  76.     {
  77.       for (int i = 0; i < num_trials; i++)
  78.     {
  79.       before[i] = System.currentTimeMillis();
  80.       first_child.set_x(i);
  81.       mid[i] = System.currentTimeMillis();
  82.       last_child.x();
  83.       after[i] = System.currentTimeMillis();
  84.     }
  85.     }
  86.  
  87.   public static void main(String argv[]) 
  88.     {
  89.       long start_t, end_t;
  90.       float sum;
  91.  
  92.       System.out.println("setting up...");
  93.       setup();
  94.       System.out.println("faulting pages...");
  95.       first_child.set_x(99);
  96.       last_child.x();
  97.       System.out.println("doing " + num_trials + " trials...");
  98.  
  99.       start_t = System.currentTimeMillis();
  100.       test();
  101.       end_t = System.currentTimeMillis();
  102.       // System.out.println("end time = " + end_t);
  103.       // System.out.println("start time = " + start_t);
  104.       System.out.println("elapsed time = " + (end_t - start_t));
  105.       System.out.println("attrs/sec = "+ 
  106.              (((float)chain_size*num_trials)*1000.0)/((float)(end_t-start_t)));
  107.  
  108.       System.out.println("doing " + num_trials + " trials of split test...");
  109.       split_test();
  110.  
  111.       sum = (float)0.0;
  112.       for (int i = 0; i<num_trials; i++)
  113.     sum += (float)(mid[i] - before[i]);
  114.       System.out.println("ood/sec = "+ (500.0*1000.0*(float)num_trials)/sum);
  115.  
  116.       sum = (float)0.0;
  117.       for (int i = 0; i<num_trials; i++)
  118.     sum += (float)(after[i] - mid[i]);
  119.       System.out.println("eval/sec = "+
  120.              (1000.0*(float)chain_size*num_trials)/sum);
  121.     }
  122. }
  123.  
  124. /*=========================== COPYRIGHT NOTICE ===========================
  125.  
  126. This file is part of the subArctic user interface toolkit.
  127.  
  128. Copyright (c) 1996 Scott Hudson and Ian Smith
  129. All rights reserved.
  130.  
  131. The subArctic system is freely available for most uses under the terms
  132. and conditions described in 
  133.   http://www.cc.gatech.edu/gvu/ui/sub_arctic/sub_arctic/doc/usage.html 
  134. and appearing in full in the lib/interactor.java source file.
  135.  
  136. The current release and additional information about this software can be 
  137. found starting at: http://www.cc.gatech.edu/gvu/ui/sub_arctic/
  138.  
  139. ========================================================================*/
  140.